import Vue from "vue";
export default {
	name: "RouterLink",
	functional: true,
	props: {
		to: {
			require: true,
			type: String,
		},
		tag: {
			default: "a",
		},
	},
	render: function (createElement, { data, props, children }) {
		data.on = {
			click: function (event) {
				// 禁用a标签默认行为
				event.preventDefault();
				Vue.prototype.$router.push(props.to);
			},
		};
		data.attrs.href = props.to;
		return createElement(props.tag, data, children);
	},
};
